//
//  RootSideController.m
//  iCarStyle
//
//  Created by liu nian on 14-5-4.
//  Copyright (c) 2014年 liunian. All rights reserved.
//

#import "RootSideController.h"
#import "CRNavigationController.h"
#import "CRNavigationBar.h"
#import "XTCenterViewController.h"
#import "XTLeftMenuViewController.h"
#import "XTRightMenuViewController.h"

#import "CenterNewsViewController.h"
#import "PictureViewController.h"
#import "InsuranceController.h"
#import "FavViewController.h"
#import "AboutController.h"

@interface RootSideController ()

@end

@implementation RootSideController

+ (instancetype)rootViewController
{
    CenterNewsViewController*first = [[CenterNewsViewController alloc] init];
    PictureViewController *second  = [[PictureViewController alloc] init];
    InsuranceController *third     = [[InsuranceController alloc] init];
    FavViewController *fouth       = [[FavViewController alloc] init];
    AboutController *fifth         = [[AboutController alloc] init];

    XTCenterViewController *center = [[XTCenterViewController alloc] init];
    [center setViewControllers:@[[RootSideController nav:first],
                                 [RootSideController nav:second],
                                 [RootSideController nav:third],
                                 [RootSideController nav:fouth],
                                 [RootSideController nav:fifth]]];

    XTLeftMenuViewController *leftMenu = [[XTLeftMenuViewController alloc] init];

    XTRightMenuViewController *rightMenu = [[XTRightMenuViewController alloc] init];

    RootSideController *sideMenuViewController = [[RootSideController alloc] initWithContentViewController:center
                                                                                    leftMenuViewController:leftMenu
                                                                                   rightMenuViewController:rightMenu];

    sideMenuViewController.panFromEdge = NO;
    sideMenuViewController.scaleMenuView = YES;
    sideMenuViewController.scaleBackgroundImageView = NO;
    sideMenuViewController.interactivePopGestureRecognizerEnabled = NO;
    sideMenuViewController.panGestureEnabled = NO;
    sideMenuViewController.backgroundImage = IMGNAMED(@"Menu_Bg");
//    sideMenuViewController.menuViewOpacity = NO;

    return sideMenuViewController;
}

+ (UINavigationController *)nav:(UIViewController *)sender
{
    //用来调节navgationBar颜色的

    //reference：http://www.cocoachina.com/applenews/devnews/2013/1024/7233.html

    CRNavigationController *nav = [[CRNavigationController alloc] initWithRootViewController:sender];
    CRNavigationBar *navigationBar = (CRNavigationBar *)nav.navigationBar;
//    [navigationBar displayColorLayer:YES];
//    navigationBar.barTintColor = [UIColor colorWithRed:0.776471 green:0.196078 blue:0.207843 alpha:1.0];
    return nav;
}

@end
